# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-uri
_pkgname=uri
pkgver=4.2.0
pkgrel=0
pkgdesc="RFC3986 URI/URL parsing library for OCaml"
url="https://github.com/mirage/ocaml-uri"
arch="all !riscv64"  # limited by ocaml aport
license="ISC"
depends="
	ocaml-runtime
	ocaml-angstrom
	ocaml-stringext
	ocaml-ppx_sexp_conv
	ocaml-re
	"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-angstrom-dev
	ocaml-stringext-dev
	ocaml-ppx_sexp_conv-dev
	ocaml-re-dev
	"
makedepends="$depends_dev dune ocaml"
checkdepends="ocaml-ounit-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mirage/ocaml-uri/releases/download/v$pkgver/uri-v$pkgver.tbz"
builddir="$srcdir/$_pkgname-v$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
119e39bf53db9e94383a4e3a3df492b60b2db097266b3a8660de431ad85bc87997718305972fd2abbfb529973475ce6b210ba5e34d12e85a5dabbb0e24130aa1  ocaml-uri-4.2.0.tar.bz2
"
